package com.feibi.study.UI

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.feibi.study.Adapter.ChildAdapter
import com.feibi.study.Basic.BasicActivity
import com.feibi.study.R
import kotlinx.android.synthetic.main.activity_list_view.*

class ListViewActivity : BasicActivity() {
    var data = arrayListOf<String>("12321","4342","!@421","4342")

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_list_view)

        rv_list.layoutManager = LinearLayoutManager(this)
//        rv_list.layoutManager = LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false)
//        rv_list.layoutManager = GridLayoutManager(this,3)
        rv_list.adapter = ChildAdapter(this,data)

        srl.setOnRefreshListener {
            refresh()
        }
    }

    fun refresh(){
        Handler().postDelayed({
            data.add("qqqqqq")
            rv_list.adapter?.notifyDataSetChanged()
            srl.isRefreshing = false
        },1000)
    }
}